package com.tgy.controller;


import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.tgy.entity.Student;
import com.tgy.util.robot;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/ai")
public class sendMsgToAi {

    @GetMapping("/send")
    public String send(String string){
        //接收返回的结果
        String result = robot.getResult("你好");
        //把json格式的字符串转化为json对象
        JSONObject resultJson = JSON.parseObject(result);

        //获得text键的内容，并转化为string
        String back = resultJson.get("text").toString();
        return back;
    };
    @RequestMapping("/get")
    public String get(Student student){
        return student.getName();
    };


}
